<?php

namespace app\controllers;

use Yii;
use yii\web\Controller;
use app\models\EntryForm;
class MapController extends Controller
{
    public function actionIndex()
    {
        return $this->render("index");
    }

    public function actionAddress_do()
    {
        $address = Yii::$app->request->post("address");
        $data = file_get_contents("http://api.map.baidu.com/geocoding/v3/?address=$address&output=json&ak=2w7khOEnOFEeEos910GCvte05KwMng9G");
        $res = json_decode($data,true);
        ///var_dump($res);die;
        return $this->render("index",['lng'=>$res['result']['location']['lng'],'lat'=>$res['result']['location']['lat']]);
    }
}
